net/tftp: Fix stack buffer overflow in tftp_open()
authorB Horn <b@horn.uk>
Thu, 18 Apr 2024 16:32:34 +0000 (17:32 +0100)
committerMiao Wang <shankerwangmiao@gmail.com>
Sun, 15 Feb 2026 13:50:20 +0000 (13:50 +0000)
commit6b512fa44cabb6277479010a370194e023d39d1c
tree2e7695ec9c6d57b987a084424691330dcc9de91a
parentb7b0cf8d1e308a3ece1874ab7735c24be9827766
net/tftp: Fix stack buffer overflow in tftp_open()

An overly long filename can be passed to tftp_open() which would cause
grub_normalize_filename() to write out of bounds.

Fixed by adding an extra argument to grub_normalize_filename() for the
space available, making it act closer to a strlcpy(). As several fixed
strings are strcpy()'d after into the same buffer, their total length is
checked to see if they exceed the remaining space in the buffer. If so,
return an error.

On the occasion simplify code a bit by removing unneeded rrqlen zeroing.

Reported-by: B Horn <b@horn.uk>
Signed-off-by: B Horn <b@horn.uk>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Gbp-Pq: Topic cve-2025-jan
Gbp-Pq: Name net-tftp-Fix-stack-buffer-overflow-in-tftp_open.patch
grub-core/net/tftp.c